package com.cloudcc.mobile.presenter;

import com.cloudcc.cloudframe.bus.DataEvent;
import com.cloudcc.cloudframe.net.ErrorInfo;
import com.cloudcc.cloudframe.net.ResultCallBack;
import com.cloudcc.mobile.dao.ContactEngine;
import com.cloudcc.mobile.dao.impl.ContactEngineImpl;
import com.cloudcc.mobile.entity.ChatUser;
import com.cloudcc.mobile.view.main.fragment.IContactUserInfo;

public class ContactPresenter extends
		GenericPresenter<IContactUserInfo, ContactEngine> {

	public ContactPresenter(IContactUserInfo view) {
		super(view);
		mEngine = new ContactEngineImpl();
	}

	/**
	 * 获取通讯录用户的详情 通过 chatter接口
	 * 
	 * @param userId
	 */
	public void getUserInfoChatter(String userId) {
		final DataEvent<ChatUser> event = new DataEvent<ChatUser>();
		mEngine.getUserInfoChatter(userId, new ResultCallBack<ChatUser>() {
			@Override
			public void onSuccess(ChatUser user) {
				if (isNotRegistering()) {
					return;
				}
				event.setOk(true);
				event.setData(user);
				mUI.onGettedUser(event);
			}

			@Override
			public void onFailure(ErrorInfo error) {
				if (isNotRegistering()) {
					return;
				}
				event.setOk(false);
				event.setMessage(error.getErrorMessage());
				mUI.onGettedUser(event);
			}
		});
	}

	
	
}
